package com.p2p.backend.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import com.p2p.base.dao.BaseMapper;

/**
 * leiwen@yiqihao.com
 */
public interface RolePrivilegeDao extends BaseMapper {
	
	@Insert("insert into p2p_role_privilege(role_id,privilege_acl) values (#{role_id},#{privilege_acl})")
	void add(Map<String, Object> params);

	@Delete("delete from p2p_role_privilege where role_id=#{roleId}")
	void deleteByRole(Integer roleId);
	
	@Delete("delete from p2p_role_privilege where privilege_acl=#{privilegeAcl}")
	void deleteByPrivilege(Integer privilegeAcl);
	
	@Select("select rp.*,p.name,p.acl from p2p_role_privilege rp left join p2p_privilege p on p.acl=rp.privilege_acl where role_id=#{id}")
	List<Map<String, Object>> listByRole(Integer id);

	@Select("select * from p2p_role_privilege where privilege_acl = #{acl}")
	List<Map<String, Object>> listByPrivilege(Integer acl);
}
